home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Texty / crackme / hf-scm3.txt < prev    next >
Encoding:
Text File  |  1999-07-10  |  6.7 KB  |  172 lines

  1.                   ░               
  2.           ░       ░      ░                                  ▄▓
  3.     ▄▄     ░░     ▄▄▄▄■  ░░▀   ■▄▄▄         ▄▄             ▐█▓▌  
  4.  ▄▀▀  ▀■      ▀        ░░            ▀    ■▀  ▀▀▄           ██▌
  5. ■        ▄▄▀▀ ▄▄██▀██▄▄       ▄▄▄███▄▄ ▀▄▄       ■  ▄▄▄███▄▄▐██     ▄▄████▄▄
  6.  ▀▄▄  ▄▀▀   ▄███▀   ▀██▓▄   ▄████▀ ▀██▓▄  ▀▄  ▄▄▀ ▄████▀ ▀██▓██   ▄████▀ ▀██▓▄
  7.     ▀▀  ▄  ▐███▌  ░  ▐██▓▌ ▐████▌ ░ ▐██▓▌ ▄ ▀▀   ▐████▌ ░ ▐████▌ ▐████▌   ▐██▓▌
  8.  ■██▄▄▓▌   ████  ░▒░  ████ █████▄▄▄  ▀▀▀▀ ▐█▄▄█▓ █████  ░  █████ █████▄▄▀▀▀▀▀▀▀
  9.   ▐████ ░░ ▓██▌ ░▒▓▒░ ▐███ ▄▄▄▄▄  ▀▀▀████▄ ████▌ ▓███▌     ▐████ ▓███▌   ░░░░░░
  10. ░  ███▌ ░ ▐▓███ ░▒▓▒░ ▓███▌▓███▌ ░░░ ▐████ ▐▓██  ▓███▌ ▄▀▀ ▐████ ▓███▌ ░░░░░░░
  11.    ▓██▌   ▐▓███  ░▒░  ▓███▌▐▓███  ░  ▓███▌ ▐▓██  ▐▓███     ▓███▌ ▐▓███    
  12.   ▐▓███   ▐▓▓██▌  ░  ▐▓███▌ ▓▓██▌   ▐▓███  ▓███▌  ▓▓██▌ ░ ▐▓███   ▓▓██▌   
  13.   ▓▓▓██▌ ■▓▓▓▓██  ░  ▓█████■ ▀▓▓█▄ ▄▓██▀  ▐▓████ ▄ ▀▓██▄ ▄▓██▀     ▀▓██▄  
  14.    ▀▓███▄   ▀▀▀██▄  ▄▓█▀▀▀      ▀▀█▀▀    ▄▓▓▓▀▀       ▀▀█▀▀           ▀▀▀▀ js
  15.        ▀▀▀▀▀▄▄           ░ inside   ▄▄▀▀▀▀▀ 
  16.           ░   ▀▄  ░     ░░        ▄▀
  17.          ░░       ░      ░░ 
  18.  
  19. Tutor        : duelist
  20. Date Wrote   : May 10, 1999
  21. Level (1/10) : 2
  22. Target       : Hellforge Softice Crackme 3
  23. Size         : 120kb
  24. Protection   : Anti-Softice, Packed, Name/Serial
  25. Tools Used   : SoftIce
  26.  
  27.  
  28.  - INTRODUCTION: -
  29.  
  30.  Before anything else i would like to say that i rated this
  31.  crackme with 2 because of the softice check, it is very
  32.  easy and about everyone should be able to reverse it. We'll
  33.  start with 'killing' that check (+ analysing the code around
  34.  it...)
  35.  
  36.  Advice: I won't say what you have to type in softice, only
  37.          what do you need to do, or else you won't learn!
  38.  
  39.  
  40.  - CRACKING ANTI-SICE CHECK: -
  41.  
  42.  Most of the programs that have this kind of check (actually,
  43.  these are mostly used in crackmes) use the CreateFileA with
  44.  '\\.\SICE' as the file parameter, so it won't be hard to kill
  45.  this one.
  46.  
  47.  1. Switch to softice and set a breakpoint on CreateFileA
  48.  2. Back to windows and execute the crackme
  49.  3. You'll break just after executing it, just ignore that
  50.     break because Explorer calls CreateFileA whenever some
  51.     application is executed... (go back to windows)
  52.  4. You'll break again, this time it's not normal and it 
  53.     should be due to some call inside the program. Press F12
  54.     and you'll be inside the crackmes' code:
  55.  
  56.     push    00435314                   <- dump this address to see it is
  57.     call    KERNEL32!CreateFileA          '\\.\SICE', it's our check!
  58.     mov    [ebp-04], eax
  59.     cmp    dword ptr [ebp-04], -01    <- does '\\.SICE' exist? if yes,
  60.  /----< jz    00401625                      softice loaded, don't jump!
  61.  |    push    dword ptr [ebp-04]
  62.  |    call    KERNEL32!CloseHandle       <- close the file if it existed
  63.  |    mov    eax, 1               <- important! eax is set to 1 if
  64.  |    pop    ecx                  softice was loaded
  65.  |    pop    ebx
  66.  |    ret
  67.  |---->    xor    eax, eax                   <- no softice loaded, set eax
  68.  |    pop     ecx                   to 0
  69.  |    pop    ebx
  70.  |    ret
  71.  |    
  72.  \-! Stop at this line and do the following: "a" to edit the code
  73.      in it, then "jmp 401625" to make it jump always and press
  74.      Escape to get out of code editing mode. Why did i do this?
  75.      Later in the program this routine will be used for another
  76.      thing, and since we don't want to be checking when its run
  77.      again, just leave it patched the correct way!
  78.  
  79.      SIDE-NOTE: For winNT users: The program will also check for
  80.                 '\\.\NTICE' by using this snippet of code, if u
  81.             change the code this way, you'll spare some time!
  82.  
  83.  5. Now that you understood this snippet of code, let the program
  84.     run after the ret instruction, and after some steping we'll be
  85.     here:
  86.  
  87.     test    eax, eax
  88.  /----<    jz    40156D
  89.  |    mov    dword ptr [00439200], 00000006
  90.  |     jmp    00401577                        >--\
  91.  \---->    mov    dword ptr [00439200], 00000005     |
  92.     mov    edx, [ebp-28]            <--/
  93.  
  94.     What this snippet of code does is to set the offset 00439200 to
  95.     5 if softice is npt loaded and to 6 if softice is loaded. You
  96.     may think: why is this done if the app only runs when softice is
  97.     _not_ loaded? This tricks people who just reverse the flag in the
  98.     softice check routine, since it is executed later again to load
  99.     the correct value into the offset. Nice work LaZaRuS :)
  100.  
  101.  
  102.  - CRACKING NAME/SERIAL CHECK: -
  103.  
  104.  1. Enter any name and serial you wish
  105.  2. Switch to softice and set a breakpoint on hmemcpy (this is a delphi
  106.     app, so standard api calls are not issued to get editbox's text)
  107.  3. Delete any char in your name or serial (since they are checked in
  108.     real time, we've no button)
  109.  4. Ignore the first break on hmemcpy, that's just windows erasing the
  110.     char... Next time it breaks, press F12 until you get to the crackme's
  111.     code.
  112.  5. Now, i don't include much code here because the target is packed and
  113.     i've got other things than manually reproducing code here. Set a break-
  114.     point on 004017AF (bpx 4017AF) and you should break at the code genera-
  115.     tion routine:
  116.  
  117.   /--->    movsx    ecx, byte ptr [eax]      <- move each letter of the name into ecx
  118.   |    xor    ecx, [ebp-54]            <- xor ecx with the counter
  119.   |    imul    ecx, [00439200]          <- remember this offset? should be 5!
  120.   |    add    [ebp-50], ecx            <- add the value to this offset
  121.   |    ...
  122.   |    inc    dword ptr [ebp-54]       <- increase counter
  123.   |    ...    
  124.   |    ...
  125.   |    test    ecx, ecx                 <- end of name reached?
  126.   \---<    jnz    00401783                 <- if no, go back to the beginning
  127.      ...
  128.     ...
  129. __/    mov    eax, [ebp-50]            <- code is at ebp-50 now...
  130. | \    imul    eax, [ebp-50]         <- code = code * code (square of code) 
  131. |    
  132. |
  133. \-! These 2 lines of code are executed when all the name has been parsed
  134.     by the above routine...
  135.  
  136.  6. You now have all the info you need to code a keygenerator, you can check my
  137.     pascal source below if you want to (or you can't code one :)
  138.  
  139.  
  140.  - CODING A KEYGENERATOR: -
  141.  
  142.    ...
  143.  
  144.    write('   Enter name: ');
  145.    readln(name);
  146.    for i:=1 to length(name) do
  147.    begin
  148.     ecx:=ord(name[i]);
  149.     ecx:=ecx xor i;
  150.     ecx:=ecx * 5;
  151.     ebp:=ebp + ecx;
  152.    end;
  153.    ebp:=ebp * ebp;
  154.    str(ebp, code);
  155.    writeln('   Registration code: ', code);
  156.  
  157.    ...
  158.  
  159.  - FINAL REMARKS & THX: -
  160.  
  161.    Hope you enjoyed this tut, i've tried to not only show you things by a
  162.    'distant' look, but see them deeply, so you can't miss anything. Also
  163.    i hope you learn something about keygens by looking at this tut...
  164.  
  165.    Thx 2: E_Bliss for kinda 'forcing' me to write tuturials
  166.       LaZaRuS for writing this crackme
  167.       tC for being such a nice friend with some nice crackmes
  168.       MisterE for showing me the way to go ;)
  169.       Everyone that _wants to learn_ at #cracking4newbies!
  170.  
  171.  
  172.                                           signing off, duelist [isd]